<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>微信支付</title>
</head>
<body>
微信支付
<p onclick="ajax_pay()">点我进行支付</p>
</body>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
    (function ($) {
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }
    })(jQuery);

    function ajax_pay() {
        var ID = $.getUrlParam('id');
        var prepay_url = '{% url "supply_order:h5pay" %}';
        alert(prepay_url)
        alert(ID)
        $.ajax({
            data: {"supply_id": ID, "trade_type": "fixed"},
            cache: true,
            type: "post",
            url: prepay_url,
            async: false,
            success: function (res) {
                if (res.errmsg) {
                    alert(res.errmsg);
                    return false
                }
                window.location.href = res.mweb_url
            }
        });
    }

</script>
</html>
